<!DOCTYPE html>
<html>
<head>
    <title>加工库存计算工具</title>
    <style>
        body { font-family: 'Segoe UI', Arial; max-width: 800px; margin: 40px auto; }
        .container { padding: 20px; box-shadow: 0 0 10px rgba(0,0,0,0.1); }
        .upload-box {
            border: 2px dashed #4CAF50;
            padding: 30px;
            text-align: center;
            margin: 20px 0;
            background: #f8f8f8;
        }
        input[type="file"] { display: none; }
        .custom-upload {
            background: #4CAF50;
            color: white;
            padding: 12px 24px;
            border-radius: 4px;
            cursor: pointer;
        }
        button {
            background: #2196F3;
            padding: 12px 24px;
            font-size: 16px;
        }
        .file-info {
            margin-top: 15px;
            color: #666;
            padding: 10px;
            background: #f0f0f0;
            border-radius: 4px;
            display: none; /* 默认隐藏 */
        }
        .file-name {
            color: #2196F3;
            font-weight: bold;
        }
        .file-name {
            margin-top: 20px;
            color: #333;
            font-size: 16px;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>🔧 加工计划计算工具</h1>
        <form method="post" enctype="multipart/form-data" onsubmit="return validateForm()">
            <div class="upload-box">
                <label class="custom-upload">
                    选择 Excel 文件
                    <input type="file" name="file" accept=".xlsx, .xls" id="fileInput">
                </label>
                <!-- 文件名显示区域 -->
                <div class="file-info" id="fileInfo">
                    已选择文件: <span class="file-name" id="fileName"></span>
                </div>
            </div>
            <button type="submit">🚀 开始处理并下载</button>
        </form>
    </div>

    <script>
        // 实时显示文件名
        document.getElementById('fileInput').addEventListener('change', function(e) {
            const fileInfo = document.getElementById('fileInfo');
            const fileNameSpan = document.getElementById('fileName');

            if (this.files && this.files[0]) {
                fileNameSpan.textContent = this.files[0].name;
                fileInfo.style.display = 'block';
            } else {
                fileInfo.style.display = 'none';
            }
        });

        // 表单提交验证
        function validateForm() {
            const fileInput = document.getElementById('fileInput');
            if (!fileInput.value) {
                alert('请先选择要上传的文件！');
                return false;
            }
            return true;
        }
    </script>
</body>
</html>
